package com.sviet.game.tetriswindow.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.sviet.game.tetriswindow.R;
import com.sviet.game.tetriswindow.util.SharedPreferencesUtils;

public class HighScoreDialog extends Dialog implements OnClickListener {

	private String TAG = HighScoreDialog.class.getSimpleName();
	private Context context;
	private Button bt_ok;
	private TextView tv_high_line;
	private TextView tv_high_score;

	public HighScoreDialog(Context context) {
		super(context);
		// remove background dialog using style
		// super(context, R.style.Theme_Dialog_Translucent);
		// TODO Auto-generated constructor stub

		Log.v(TAG, "HighScoreDialog");
		this.context = context;
		Log.v(TAG, "this.context = " + this.context);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.high_score_dialog);

		// remove background dialog
		this.getWindow().setBackgroundDrawable(
				new ColorDrawable(Color.TRANSPARENT));

		tv_high_line = (TextView) findViewById(R.id.high_score_tv_high_line);
		tv_high_score = (TextView) findViewById(R.id.high_score_tv_high_score);
		tv_high_line.setText(context.getString(R.string.high_line_message) + " " 
				+ SharedPreferencesUtils.GetPreference(context, 
						SharedPreferencesUtils.LINE));
		tv_high_score.setText(context.getString(R.string.high_score_message) + " " 
				+ SharedPreferencesUtils.GetPreference(context, 
						SharedPreferencesUtils.SCORE));
		
		// Buttons
		bt_ok = (Button) findViewById(R.id.high_score_bt_ok);
		bt_ok.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v.getId() == R.id.high_score_bt_ok) {
			dismiss();
		}
	}
}
